import {
  Controller,
  Get,
  Post,
  Put,
  Body,
  Query,
  UseGuards,
  Headers,
  Delete,
  Param,
} from '@nestjs/common';
import {
  ApiBearerAuth,
  ApiOperation,
  ApiResponse,
  ApiParam,
  ApiQuery,
  ApiTags,
} from '@nestjs/swagger';
import { AuthGuard } from '@nestjs/passport';

import { BaseResponse } from '@server/basic-dto';

import SubscribeService from './service';
import { CreateSubscribeDto, QuerySubscribeResponse } from './dto';

@ApiTags('subscribe')
@Controller('/subscribe')
export default class SubscribeController {
  constructor(private readonly service: SubscribeService) {}

  @ApiOperation({
    summary: '用户订阅(提交)',
  })
  @ApiResponse({
    type: BaseResponse,
  })
  @Put('/add')
  async addSubscribe(
    @Body() createSubscribe: CreateSubscribeDto,
  ): Promise<BaseResponse> {
    return this.service.addSubscribe(createSubscribe);
  }

  @ApiOperation({
    summary: '用户订阅分页查询',
  })
  @ApiResponse({
    type: QuerySubscribeResponse,
  })
  @ApiQuery({
    name: 'page',
    description: '当前页',
    required: false,
  })
  @ApiQuery({
    name: 'pageSize',
    description: '每页多少条',
    required: false,
  })
  @Get('/list')
  async list(
    @Query('page') page: number,
    @Query('pageSize') pageSize: number,
  ): Promise<QuerySubscribeResponse> {
    return this.service.list(page, pageSize);
  }
}
